package jtk.project4.fleet.ibatis.dao;

import java.sql.SQLException;
import java.util.List;

import nl.coderight.jazz.dialog.MessageDialog;
import nl.coderight.jazz.dialog.MessageType;
import jtk.project4.fleet.domain.Odometer;




public class OdometerDao extends IbatisDao{
	
	public List selectOdometer() throws SQLException {
		List selectOdometer = null;
			selectOdometer =getSqlMap().queryForList("SELECT_ALL_ODOMETER", null);
		return selectOdometer;
	} 

	public int deleteOdometer(Odometer odometer) throws SQLException{
		return (int) getSqlMap().delete("DELETE_ODOMETER", odometer);
	}
	
	public int updateOdometer(Odometer odometer) throws SQLException{
		return (int) getSqlMap().update("UPDATE_ODOMETER", odometer);
	}
	
	public Odometer insertOdometer(Odometer odometer) throws SQLException{
		return (Odometer) getSqlMap().insert("INSERT_ODOMETER", odometer);
	}
	
		
	public static void main (String args[]) throws SQLException{
		
		Odometer odometer;
		List<Odometer> odometers ;
		odometer = new Odometer();
		
		odometer.getCreateDate();
		odometer.setDesc("Baru");
//		odometer.setCurrentMeter(currentMeter);
//		
		odometer.setOdId(1);
		
		new OdometerDao().insertOdometer(odometer); 
		System.out.println("Deskripsi dengan nilai : "+odometer.getDesc()+ " telah di insert pada DB");
		
		new OdometerDao().insertOdometer(odometer); 
		System.out.println("odID dengan nilai : "+odometer.getOdId()+ " telah di insert pada DB");
		
		new OdometerDao().insertOdometer(odometer); 
		System.out.println("Current Meter dengan nilai : "+odometer.getCurrentMeter()+ " telah di insert pada DB");
		
		
		}
	
}